#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
自定义操作自动化系统 - 主程序入口
修复版：解决模块循环依赖问题
"""

import sys
import os
import tkinter as tk
from tkinter import messagebox

# 添加当前目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

def main():
    """主程序入口"""
    try:
        # 延迟导入，避免循环依赖
        from config_window import EnhancedOperationConfigWindow
        from sequence_manager import OperationSequenceManager
        
        print("正在启动自定义操作自动化系统...")
        
        # 创建操作序列管理器
        sequence_manager = OperationSequenceManager()
        
        # 创建配置窗口
        config_window = EnhancedOperationConfigWindow(sequence_manager)
        
        # 启动主循环
        config_window.root.mainloop()
        
    except ImportError as e:
        print(f"导入模块失败: {e}")
        messagebox.showerror("错误", f"无法启动程序，缺少必要的模块: {e}")
    except Exception as e:
        print(f"程序启动失败: {e}")
        messagebox.showerror("错误", f"程序启动失败: {e}")

if __name__ == "__main__":
    main()